import store from '@/store'

export default (showModal = true) => {
	return new Promise((resolve,reject) => {
		const user_info = store.state.userInfo
		if(user_info && Object.keys(user_info).length) {
			resolve();
		} else {
			if(showModal) {
				uni.showModal({
					content: "未登录，是否立即登录？",
					confirmColor: '#4790fd',
					success: (res) => {
						if(res.confirm) {
							uni.reLaunch({
								url: "/pages/login/login"
							})
						}
					}
				})
			} else {
				// uni.showToast({
				// 	icon: 'none',
				// 	title: "未登录!"
				// })
			}
			reject();
		}
	})
}